/**
 * 
 */
package com.woupla.model;

import java.io.Serializable;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotEmpty;

/**
 * @author dimi
 * 
 */
@NamedQueries({
		@NamedQuery(name = "findUserByPseudo", query = "SELECT u FROM User u WHERE u.pseudo = :pseudo ")
})
@Entity
public class User implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 9085875213223561286L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int id;
	@NotNull
	@NotEmpty
	@Size(min = 3, max = 25)
	@Pattern(regexp = "[A-Za-z0-9]*")
	@Column(unique=true)
	private String pseudo;
	@Size( max = 40)
	@Pattern(regexp = "[A-Za-z ]*")
	private String firtName;
	@Size(max = 40)
	@Pattern(regexp = "[A-Za-z ]*")
	private String lastName;
	@Email
	private String email;
	@NotNull
	@NotEmpty
	@Size(min = 6, max = 100)
	//@Pattern(regexp = "[A-Za-z0-9 ]*")
	private String password;
	@NotNull
	private boolean sex;
	@NotNull
	private String role;
	@ManyToOne
	@JoinColumn(name = "company_id", referencedColumnName = "id")
	private Company company;

	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return the pseudo
	 */
	public String getPseudo() {
		return pseudo;
	}

	/**
	 * @param pseudo the pseudo to set
	 */
	public void setPseudo(String pseudo) {
		this.pseudo = pseudo;
	}

	/**
	 * @return the firtName
	 */
	public String getFirtName() {
		return firtName;
	}

	/**
	 * @param firtName
	 *            the firtName to set
	 */
	public void setFirtName(String firtName) {
		this.firtName = firtName;
	}

	/**
	 * @return the lastName
	 */
	public String getLastName() {
		return lastName;
	}

	/**
	 * @param lastName
	 *            the lastName to set
	 */
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * @param email
	 *            the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password
	 *            the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}
	/**
	 * @return the sex male = 1 , female = 0
	 * 
	 */
	public boolean isMale() {
		return sex;
	}
	/**
	 * @param sex
	 *            the sex to set
	 */
	public void setSex(boolean sex) {
		this.sex = sex;
	}

	/**
	 * @return the role
	 */
	public String getRole() {
		return role;
	}

	/**
	 * @param role the role to set
	 */
	public void setRole(String role) {
		this.role = role;
	}

	/**
	 * @return the company
	 */
	public Company getCompany() {
		return company;
	}

	/**
	 * @param company the company to set
	 */
	public void setCompany(Company company) {
		this.company = company;
	}

}
